class Functions {
    static createBitmapByName(name) {
        let result = new egret.Bitmap();
        let texture = RES.getRes(name);
        result.texture = texture;
        return result;
    }
    static sendGetRequest(url, callback?) {
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(url, egret.HttpMethod.GET);
        request.send();
        request.addEventListener(egret.Event.COMPLETE, function (e) {
            if (callback) callback(JSON.parse(e.currentTarget.response))
        }, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, function (e) {
            if (callback) callback(JSON.parse(e.currentTarget.response))
        }, this);
    }
    static sendPostRequest(url, data, callback?) {
        var request = new egret.HttpRequest();
        request.responseType = egret.HttpResponseType.TEXT;
        request.open(url, egret.HttpMethod.POST);
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send(data);
        request.addEventListener(egret.Event.COMPLETE, function (e) {
            if (callback) callback(JSON.parse(e.currentTarget.response))
        }, this);
        request.addEventListener(egret.IOErrorEvent.IO_ERROR, function (e) {
            if (callback) callback(JSON.parse(e.currentTarget.response))
        }, this);
    }
    static drawBorderLine(stage, width, height) {
        let iFillColor = 0x000000;
        let outline = new egret.Shape;
        outline.graphics.clear();
        outline.graphics.lineStyle(1, iFillColor);
        outline.graphics.beginFill(0x000000, 0);
        outline.graphics.drawRect(0, 0, width, height);
        outline.graphics.endFill();
        stage.addChild(outline);
    }
    static animateBeat(object) {
        egret.Tween.get(object).to({
            scaleX: 1.08,
            scaleY: 1.08
        }, 100).to({
            scaleX: 1,
            scaleY: 1
        }, 50)
    }
}

